<!DOCTYPE html>
<html>
<head>
    <title>Title</title>
    <#include "head.ftl"/>
</head>
<body class="margin-0">
<form class="layui-form" action="">
    <div class="edit-bar">
        <button type="submit" class="layui-btn layui-btn-sm layui-btn-danger" lay-submit="" lay-filter="gencode">生成代码</button>
    </div>
    <div class="layui-row edit-form">
        <div class="layui-col-md6">
            <label class="layui-form-label">projectName</label>
            <div class="layui-input-inline">
                <input type="text" name="projectName" autocomplete="off" placeholder="请输入标题" class="layui-input"/>
            </div>
        </div>
        <div class="layui-col-md6">
            <label class="layui-form-label">group</label>
            <div class="layui-input-inline">
                <input type="text" name="group" autocomplete="off" placeholder="请输入标题" class="layui-input"/>
            </div>
        </div>
    </div>
</form>
<script type="application/javascript">
//UI初始化
layui.use(['element', 'layer', 'form', 'table'], function () {
    var form = layui.form;
    var layer = layui.layer;
    //自定义验证规则
    form.verify(verify_rule);
    //监听提交
    form.on('submit(gencode)', function (data) {
        $.ajax({
            url: "/project/build",
            dataType: "json",
            method: "POST",
            data: data.field,
            success: function (result) {
                if (result.code > 0) {
                    layer.msg(result.msg, {
                        time: 1000
                    });
                } else {
                    layer.alert(result.msg);
                }
            }
        });
        return false;
    });
});
</script>
</body>
</html>